package com.zjeav.lingjiao.base.tools;

import java.io.File;

import okhttp3.MediaType;
import okhttp3.RequestBody;

/**
 * Created by 5zhi on 2016/9/18.
 */
public class RetrofitMutiPartTool {
    //Mutipart的String直接传会多一对引号，必须转成Requestbody才行
    public static RequestBody toRequestBody(String value) {
        return RequestBody.create(MediaType.parse("text/plain"), value);
    }

    public static RequestBody toRequestBody(File value) {
        RequestBody body = RequestBody.create(MediaType.parse("multipart/form-data"), value);
        return body;
    }

    public static RequestBody toRequestBody(byte[] value) {
        RequestBody body = RequestBody.create(MediaType.parse("multipart/form-data"), value);
        return body;
    }
}
